#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018/1/27 0027 15:37
# @Author  : Arliki
# @email   : hkdnxycz@outlook.com
# @File    : for_numpy

import numpy as np
from numpy import array


def run():
    a1 = [1, 2, 3, 4, 5, 6]  # np.arange(4)
    b1 = [
        [1, 2, 3],
        [3, 4, 5],
        [5, 6, 7]
    ]  # np.arange(12).reshape(3,3)
    c1 = [
        [
            [1, 2, 3],
            [3, 4, 5]
        ],

        [
            [5, 6, 7],
            [7, 8, 9]
        ]
    ]  # np.arange(12).reshape(2,2,3)
    a1 = array(a1)
    b1 = array(b1)
    c1 = array(c1)
    # print(a1)
    # print(b1)
    # print(c1)
    # print("切片")
    # print("所有")
    # print(a1[:])
    # print(b1[:,:])
    # print(c1[:,:,:])
    # print("步长(每x个取一个)[负数为倒置后跳过取值]")
    # print(a1[::2])
    # print(b1[:,::2])
    # print(c1[:,:,::2])
    # print("取值：前两行前两列")
    # print(b1[0:2,0:2])
    # print(c1[:,0:2,0:2])
    # print("取值：后两行后两列")
    # print(b1[-2:, -2:])
    # print(c1[:, -2:, -2:])

    # print(a1.min())
    # print(a1.dtype)  # 返回类型
    # print(a1.view())  # 复制a1给**
    # print(a1.copy())  # 复制a1给**
    # print(a1.astype(float))  # 修改类型
    # print(b1.sum(axis=1))  # 按行求和 1 行,0列
    # print(b1.sum(axis=1))  # 按行求和 1 行,0列
    # c = (b1[:, 2] == 5)  # b1所有行第三列=5返回bool/index
    # print(b1[c])
    # b1[c, 2] = -1  # 将上述寻找的值修改为-1
    # print(len(b1))
    # print(b1.shape)  # 行列
    # print(b1.ndim)  # 维度
    # print(a1.shape(2, 3)) #list 2 array
    # print(a1.reshape(3, 2)) # 重新排列a1
    # print(b1.ravel())  # array 2 list
    # print(b1.T)  # 转置
    a = array([[1.3, 2],
               [3.9, 4]])
    b = array([[10, 20],
               [30, 40]])
    # print(a.dot(b))
    # print(np.dot(a, b))
    print(np.floor(a))
    # print(np.hstack((a, b)))  # ab水平拼接
    # print(np.vstack((a, b)))  # ab垂直拼接
    # print(np.dstack((a, b)))  # ab深度拼接
    print(np.hsplit(a, 2))  # a 切分 平均
    print(a.argmax(axis=0))  # 返回a中每列最大值的坐标
    print(np.hsplit(a, (2, 3)))  # a 切分 在2,3处切分  对应vsplit


if __name__ == '__main__':
    run()
